//
//  SelectCityWithSearchBarView.m
//  Medicine.Power
//
//  Created by 钟毅灵 on 15/8/4.
//  Copyright (c) 2015年 钟毅灵. All rights reserved.
//

#import "SelectCityWithSearchBarView.h"

@implementation SelectCityWithSearchBarView

- (instancetype) init {
    self = [super init];
    if (self) {
        [self addSubview:self.cityLabel];
        [self addSubview:self.searchBar];
        
        [self.cityLabel makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.mas_equalTo(@-10);
        }];
        
        [self.searchBar makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cityLabel.right).offset(@10);
            make.centerY.equalTo(self);
            make.height.mas_equalTo(22);
            make.width.mas_equalTo(ScreenWidth - 100);
        }];
        
    }
    return self;
}

- (UILabel *) cityLabel {
    if (!_cityLabel) {
        _cityLabel = [UILabel new];
        [_cityLabel setText:@"定位中"];
        [_cityLabel setFont:[UIFont systemFontOfSize:16]];
        [_cityLabel setTextAlignment:NSTextAlignmentLeft];
        [_cityLabel setTextColor:[UIColor whiteColor]];
    }
    return _cityLabel;
}

- (UISearchBar *) searchBar {
    if (!_searchBar) {
        _searchBar = [UISearchBar new];
        _searchBar.placeholder = @"请输入";
        _searchBar.searchBarStyle = UISearchBarStyleProminent;
        _searchBar.layer.cornerRadius = 2;
    }
    return _searchBar;
}


@end
